<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Advertisement extends Model
{
    protected $fillable = [
        'title',
        'location',
        'is_title_show',
        'cover',
        'start_time',
        'end_time',
        'jump_link',
        'jump_type',
        'sort',
        'status',
        'silder_text'
    ];

    const LOCATION_INDEX_TOP = "index_top";
    const LOCATION_INDEX_HOT = "index_hot";
    const LOCATION_INDEX_NEW = "index_new";
    const LOCATION_INDEX_RECOMMEND = "index_recommend";
    const LOCATION_CATEGORY_TOP = "category_top";

    /**
     * @var string[]
     * 广告位置
     */
    public static $locationMap = [
        self::LOCATION_INDEX_TOP => '首页顶部轮播广告图',
        self::LOCATION_INDEX_NEW => '首页新品广告图',
        self::LOCATION_INDEX_RECOMMEND => '首页推荐广告图',
        self::LOCATION_INDEX_HOT => '首页热门广告图',
        self::LOCATION_CATEGORY_TOP => '分类顶部广告图',
    ];

    const JUPM_TYPE_PRODUCT_VIEW = 'product_view';
    const JUPM_TYPE_PRODUCT_LIST_FOR_CATE = 'product_list_for_cate';
    const JUPM_TYPE_COUPON_CODE_VIEW = 'coupon_code_view';
    const JUPM_TYPE_PRODUCT_LIST_FOR_BRAND = 'product_list_for_brand';

    /**
     * 广告跳转类型
     * @var string[]
     */
    public static $jumpTypeMap = [
        self::JUPM_TYPE_PRODUCT_VIEW => '产品详情',
        self::JUPM_TYPE_PRODUCT_LIST_FOR_CATE => '某分类下的商品',
        self::JUPM_TYPE_COUPON_CODE_VIEW => '优惠劵详情',
        self::JUPM_TYPE_PRODUCT_LIST_FOR_BRAND => '某品牌下的商品',
    ];

    protected $casts = [
        'is_title_show' => 'boolean',
        'status' => 'boolean'
    ];

    protected $dates = [
        'start_time',
        'end_time'
    ];
}
